import {GET_DATA,ADD,DELETES,XIUGAI,SUREBTN} from "./mutations-types";

const mutations={
      [GET_DATA](state,payLoad){
          state.datas=payLoad
      },
      [ADD](state,payLoad){  //添加数据
           //console.log(payLoad)
           state.datas.push(payLoad);
           //console.log(state.datas)
      },
      [DELETES](state,payLoad){  //删除数据
           state.datas.splice(payLoad.ind,1)
      },
      [XIUGAI](state,payLoad){  //修改
          state.datas.filter((item,index)=>{
               if(index==payLoad.ind){
                   return item.flag=!item.flag
               }
          })
      },
      [SUREBTN](state,payLoad){  //修改完成
        //console.log(state.datas)
        //console.log(payLoad.ind)
        //console.log(payLoad.item)
        state.datas[payLoad.ind]=payLoad.item
        state.datas[payLoad.ind].flag=!state.datas[payLoad.ind].flag
      }
}

export default mutations;